package dao.impl;

import dao.ProvinceDao;
import domain.Province;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import util.JDBCUtils;

import java.util.List;

/**
 * @author Mc.Chai
 * @program: JavaWeb
 * @create 2022-04-23-15:30 15:30
 */
public class ProvinceDaoImpl implements ProvinceDao {

    private JdbcTemplate jdbcTemplate=new JdbcTemplate(JDBCUtils.getDataSource());
    /**
     * 查询所有的省份
     *
     * @return 所有省份的集合
     */
    @Override
    public List<Province> findAll() {
        String sql="select * from province";
        List<Province> list = jdbcTemplate.query(sql, new BeanPropertyRowMapper<Province>(Province.class));
        return list;
    }
}
